import numpy as np

# 精英保留
def elitism(population, fitness_values, new_population, elite_size):
    
    sorted_indices = np.argsort(fitness_values)  
    best_indices = sorted_indices[-elite_size:]  
    
    for i in range(len(best_indices)):  
        elite_index = best_indices[i]   
        elite = population[elite_index] 
  
        new_population[i] = elite.copy()  
    
    return new_population
